package com.example.demo.component;

//todo: 添加 @Data 注解

import javafx.beans.binding.ObjectExpression;
import lombok.Data;

@Data
public class AjaxResult {

    private Integer code;
    private String msg;
    private Object data;

    public static AjaxResult success(Object data) {
        AjaxResult ajaxResult = new AjaxResult();
        ajaxResult.code = 200;
        ajaxResult.msg = "";
        ajaxResult.data = data;
        return ajaxResult;
    }

    public static AjaxResult success(Object data, String msg) {
        AjaxResult ajaxResult = new AjaxResult();
        ajaxResult.code = 200;
        ajaxResult.msg = msg;
        ajaxResult.data = data;
        return ajaxResult;
    }

    public static AjaxResult success(Integer code, String msg, Object data) {
        AjaxResult ajaxResult = new AjaxResult();
        ajaxResult.code = code;
        ajaxResult.msg = msg;
        ajaxResult.data = data;
        return ajaxResult;
    }

    public static AjaxResult error(Integer code, String msg, Object data) {
        AjaxResult ajaxResult = new AjaxResult();
        ajaxResult.code = code;
        ajaxResult.msg = msg;
        ajaxResult.data = data;
        return ajaxResult;
    }

    public static AjaxResult error(Object data) {
        AjaxResult ajaxResult = new AjaxResult();
        ajaxResult.code = 403;
        ajaxResult.msg = "";
        ajaxResult.data = data;
        return ajaxResult;
    }

    public static AjaxResult error(Object data, String msg) {
        AjaxResult ajaxResult = new AjaxResult();
        ajaxResult.code = 403;
        ajaxResult.msg = msg;
        ajaxResult.data = data;
        return ajaxResult;
    }



}
